<?php $at_homepage = $this->account_username!="" ;?>

<style type="text/css">
<?php if ($at_homepage){ ?>
	#btn_view_all {  width: 70px ;}
	#btn_view_all-button,#btn_insert-button{margin-right: 0px;margin-left:5px;float: right;}
	.pagination div {margin-right: 0px;}
	dl.zend_form select.insert_type {float:right;width:150px;margin-left:5px}
<?php } else {?>
	.insert_type {margin-top:-5px}
	.insert_type label{text-align:left;clear:both;float:left}
<?php }?>
</style>

<?php if (!$at_homepage): ?>
	<script type="text/javascript">
		var companies = <?php echo Zend_Json::encode($this->key_companies);?>;
		$(document).ready(function(){
			$( "#inbound_company_code" ).blur(function(){
				if( companies[$(this).val()] == null ){
					$(this).val('');
				}
			});	

			$('.insert_type input').eq(0).attr('checked','checked');
		});
	</script>
<?php endif ;?>

<!-- thanh toolbar -->
<?php $this->placeholder('toolbar')->captureStart();?>
	<?php //echo $this->partial('index/toolbar/excel.phtml', 'admin') ?>
	<?php //echo $this->partial('index/toolbar/excel-all.phtml', 'admin') ?>
	<?php //echo $this->partial('index/toolbar/divider.phtml', 'admin') ?>
	<?php echo $this->partial('index/toolbar/publish.phtml', 'admin') ?>
	<?php echo $this->partial('index/toolbar/unpublish.phtml', 'admin') ?>	
	<?php echo $this->partial('index/toolbar/divider.phtml', 'admin') ?>
	<li class='insert_type'>	
		<?php foreach (Zend_Registry::get('warehouse-group')->warehouse_group_code as $key => $value){  ?>
		<label><input type='radio' name='inbound_warehouse_group_code' value='<?php echo $key?>' /> <?php echo $value?></label>
		<?php }?>
	</li>
	<?php
	$js= "javascript:window.location='".$this->url(array('action' => 'insert','controller'=>'index','module'=>'tmp-inbound'),null,true)."/inbound_warehouse_group_code/'+$('.insert_type input:checked').val()";
	echo $this->partial('index/toolbar/new.phtml', 'admin', array($js)); ?>
	<?php //echo $this->partial('index/toolbar/edit.phtml', 'admin', array($this->url(array('action' => 'update')))) ?>
	<?php //echo $this->partial('index/toolbar/divider.phtml', 'admin') ?>
	<?php //echo $this->partial('index/toolbar/trash.phtml', 'admin', array($this->url(array('action' => 'delete')))) ?>
<?php $this->placeholder('toolbar')->captureEnd();?>
<!-- / -->

<form id='adminForm' name='adminForm' method='post' action=''>
<dl class="zend_form">
		
		<!-- phần tìm kiếm -->
		<?php if (!$at_homepage): ?>	
		<div class='formSearh'>
		<fieldset>
			<legend>Thông tin tìm kiếm</legend>
			<?php echo $this->form->adminAction;?>
			<?php echo $this->form->inbound_code;?>
			<?php echo $this->form->inbound_create_time_a;?>
			<?php echo $this->form->inbound_create_time_b;?>
			<?php echo $this->form->inbound_create_user;?>
			
			<?php if(($this->report_type==1||$this->report_type==2)&&$this->inbound_type==1&&($this->inbound_warehouse_group_code=='BB' || $this->inbound_warehouse_group_code=='NVL')){?>
			<?php echo $this->form->inbound_detail_sub_product_code	;?>
			<?php }?>
			
			<?php if($this->report_type==1||$this->report_type==2){?>		
			<?php echo $this->form->product_group_code;?>
			<?php echo $this->form->inbound_detail_product_code;?>
			<?php }?>
			
			<?php echo $this->form->inbound_warehouse_code;?>
			<?php echo $this->form->inbound_reason_code;?>
			<?php echo $this->form->inbound_company_code;?>
		</fieldset>
		</div>
		<?php endif ;?>
		<!-- / -->		
		
		<!-- danh sách hiển thị -->
		<div class='clr'> </div>
		<fieldset>
			<?php if (!$at_homepage): ?>
			<legend>Danh sách phiếu <?php echo $this->string_inbound_type?> kho</legend>
			<?php endif ;?>
			<table class='adminlist'>
				<thead>
					<?php if ($at_homepage){ ?>		
					<tr>
						<td  colspan='17'>	
							<?php $js= "window.location='".$this->url(array('action' => 'insert','controller'=>'index','module'=>'tmp-inbound'),null,true)."/inbound_warehouse_group_code/'+$('.insert_type').val()";?>										
							<?php echo $this->partial('index/manage/button.phtml','admin',array('value'=>'Thêm mới','onclick'=>$js,'id'=>'btn_insert'));?>
							<select name='inbound_warehouse_group_code' class='insert_type'>
								<?php foreach (Zend_Registry::get('warehouse-group')->warehouse_group_code as $key => $value){?>
								<option selected="selected" value='<?php echo $key?>' > <?php echo $value?></option>
								<?php }?>					
							</select>
							<?php echo $this->partial('index/manage/button.phtml','admin',array('value'=>'Xem tất cả','onclick'=>"window.location='".$this->url(array("module"=>"tmp-inbound"), NULL, TRUE)."'", 'id'=>'btn_view_all'));?>	
						</td>
					</tr>
					<?php } ?>
					<tr>					
						<?php if (!$at_homepage){ ?>	
						<?php echo $this->partial('index/manage/no-save-order.phtml', 'admin', array($this->url(array('action'=>'save-order')))); ?>
						<?php }else{?>
						<th width="20px">STT</th>
						<?php }?>
						
						<th> <?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>$this->captions,'column'=>'inbound_code')); ?> </th>
						
						<?php if (!$at_homepage): ?>
						<th> <?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>$this->captions,'column'=>'inbound_note')); ?> </th>
						<?php endif ;?>							
						
						<th> <?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>$this->captions,'column'=>'inbound_create_time')); ?> </th>
						
						<?php if (!$at_homepage): ?>
						<th> <?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>$this->captions,'column'=>'inbound_create_user')); ?> </th>						
						<th> <?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>$this->captions,'column'=>'inbound_warehouse_code')); ?> </th>
						<th> <?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>"Đơn vị ".$this->string_inbound_type_2." hàng",'column'=>'company_name')); ?></th>
						<?php endif ;?>
						
						<th style='width:75px'>
							<?php echo $this->partial('index/manage/header.phtml','admin',array('caption'=>$this->captions,'column'=>'inbound_status')); ?>
						</th>
						
						<th width='120px'> Quản lý </th>
					</tr>
				</thead>
				<tbody>
				<?php if (count($this->paginator) > 0): $no=0;?>
					<?php foreach ($this->paginator as $row): ?>
					<tr class='row<?php echo ($no++)%2 ?>'>											
						<?php echo $this->partial('index/manage/order.phtml', 'admin', array($no)) ?>
						
						<td class="is_code"><?php echo $row->inbound_code ?></td>
						
						<?php if (!$at_homepage): ?>
							<td class='left'><?php echo $row->inbound_note; ?></td>
						<?php endif ;?>		
										
						<td class='center'><?php echo $this->partial('index/format/time.phtml','admin',array($row->inbound_create_time)); ?></td>
						
						<?php if (!$at_homepage): ?>
						<td class='left'><?php echo $row->inbound_create_user." - ".$row->m_Array['account_fullname']; ?></td>						
						<td class='left'><?php echo $row->inbound_warehouse_code." - ".$row->m_Array['warehouse_name']; ?></td>
						<td><?php echo $row->m_Array['company_name']; ?></td>
						<?php endif ;?>
						
						<td class='center'>
							<?php echo $this->partial('index/manage/publish.phtml','admin', array($this->url(array('action' => 'publish','module'=>'tmp-inbound','controller'=>'index','id'=>$row->inbound_id)),$row->inbound_status)); ?>	
						</td>
						<td class='center'>
							<?php echo $this->partial('index/manage/edit.phtml','admin', array($this->url(array('module'=>'tmp-inbound','controller'=>'index','action' => 'update','id'=>$row->inbound_id),null,true))); ?>					
							<?php echo $this->partial('index/manage/detail.phtml','admin', array($this->url(array('module'=>'tmp-inbound','controller'=>'index','action'=>'detail','id'=>$row->inbound_id),null,true))); ?>
							<?php echo $this->partial('index/manage/icon.phtml','admin', array('href'=>$this->url(array('module'=>'tmp-inbound','controller'=>'index','action'=>'print','id'=>$row->inbound_id),null,true),'title'=>'In phiếu','class'=>'icon-16-print')); ?>
							<?php echo $this->partial('index/manage/icon.phtml','admin', array('href'=>$this->url(array('module'=>'tmp-inbound','controller'=>'index','action'=>'copy','id'=>$row->inbound_id),null,true),'title'=>"Copy phiếu mới từ phiếu {$row->inbound_code}",'class'=>'icon-16-copy')); ?>						
						</td>
						
					</tr>
					<?php endforeach; ?>
				<?php endif;?>
				</tbody>
				<tfoot>
					<tr>
						<td colspan='17'>
							<div class='container'>
								<?php echo $this->paginationControl($this->paginator,'Sliding',($at_homepage?'small-':'').'pagination.phtml');?>								
							</div>
						</td>												
					</tr>					
				</tfoot>
			</table>
		</fieldset>
		<!-- / -->
		
</dl>
</form>